def timerange_to_minutes(t_str):
    """Возвращает колличество минут для интервалов времени
    в формате HH:MM"""
    hour = int(t_str.split(':')[0])
    minutes = int(t_str.split(':')[1])
    hour_to_minutes = hour * 60
    return hour_to_minutes + minutes


def minutes_to_timerange_str(m):
    """return a timerange string in format HH:MM
    :param m:
    :return:
    m = 90 -> 01:30"""
    hour = m // 60
    hour_str = f'{hour:02d}'
    minutes = m % 60
    minutes_str = f'{minutes:02d}'
    return f'{hour_str}:{minutes_str}'


def prettify_avalible_minutes(l:list):
    group_list = []
    list_resettable = []

    for element in l:
        if list_resettable == []:
            list_resettable.append(element)
            continue
        if list_resettable[-1] + 1 == element:
            list_resettable.append(element)
        else:
            group_list.append(list_resettable[:])
            list_resettable.clear()
            list_resettable.append(element)

    group_list.append(list_resettable)

    time_ranges = []
    for group in group_list:
        start_time = minutes_to_timerange_str(m=group[0])
        end_time = minutes_to_timerange_str(m=group[-1])
        time_range_str = f'{start_time}:{end_time}'
        time_ranges.append(time_range_str)

    return time_ranges
